Bandit Write-up Level 4

Posted by CLoveYC on April 4, 2024

Goal:

Using command to get the password which is stored in a hidden file in the 'inhere' directory.

Login command: ssh bandit3@bandit.labs.overthewire.org -p 2220

Password: aBZ0W5EmUfAf7kHTQeOwd8bauFJ2lAiG

My Solution:

In this level, we need to find a hidden file in the 'inhere' directory. First, we use 'ls' to see if there are any files to be used. After the 'ls' command, a directory called 'inhere' showed up. Therefore, we use 'cd inhere' to enter the directory. In the 'inhere' directory, we used 'ls' again. However, there didn't appear to be any files. After checking the goal, I noticed the term 'hidden file'. As a result, I used the command 'ls -l' or 'll'. The former one's output is 'total 0'. The latter one outputs nothing. When this unusual occurrence happened, I wondered if there could be anything wrong. So I consulted the man page and, to my surprise, I found a parameter that can show hidden files, which is '-a'. Therefore, I used it immediately. After typing 'ls -a', we found the hidden file called '.hidden'. Finding the file means finding the key. As the file showed up, the key can be easily obtained using the command 'cat .hidden'.

However, when I got the key and wanted to use this new parameter again, I mistyped 'ls' as 'll'. To my surprise, the system didn't show an error but instead demonstrated the hidden files and their details. I was really surprised by this consequence. So I started searching on the Internet. Some people say that 'll' is an alias for 'ls -l', which might be correct in different settings and environments. However, in my solving process, we can see that when using 'ls -l', the system's response is 'total 0'. On the other hand, when using 'll', the system displays all the details and hidden files. In my opinion, the correct equivalent of 'll' is the command parameter '-al'. It can not only show the details but also display the hidden files, whose functionality is exactly the same as 'll'.

The Key

2EW7BBsr6aMMoJ2HjW067dm8EgX26xNe



References

https://man7.org/linux/man-pages/man1/ls.1.html

https://www.quora.com/What-is-the-difference-between-ls-l-and-the-ll-command-on-Linux

https://www.scaler.com/topics/ll-command-in-linux/